package com.alibaba.citrus.cr.sales.plan.functions.salesplan;

import com.alibaba.citrus.cr.common.util.SpringContextUtil;
import com.alibaba.citrus.cr.sales.plan.repository.SalesPlanRepository;
import com.alibaba.citrus.cr.sales.plan.sdo.SalesPlanSDO;
import lombok.Getter;
import lombok.Setter;

/**
 * @author yuhailin
 * @description:
 * @date 2021-09-06 19:02
 */
public class SalesPlanEntity {
    @Getter
    @Setter
    private SalesPlanSDO salesPlanSDO;

    private static SalesPlanRepository salesPlanRepository;
    static {
        salesPlanRepository = SpringContextUtil.getBean(SalesPlanRepository.class);
    }

    public static SalesPlanEntity of(SalesPlanSDO sdo) {
        SalesPlanEntity entity = new SalesPlanEntity();
        entity.setSalesPlanSDO(sdo);
        return entity;
    }

    public String save(){
        return salesPlanRepository.save(this.salesPlanSDO);
    }

    public Boolean edit() {
        return salesPlanRepository.edit(this.salesPlanSDO);
    }

    public Integer updateSalesPlanStatus(){
        return salesPlanRepository.updateSalesPlanStatus(this.salesPlanSDO);
    }
}
